#include "../begonia.h"
#include "boss_1_4.h"
#include "../base/scene.h"

boss_1_4::boss_1_4():boss(192.0,250.0,20.0,0.0,0.0,&f.head)
    {
        aimx=f.px;aimy=f.py;
    }
boss_1_4::boss_1_4(double tx,double ty,double tr,double tvx,double tvy,bullet *h):boss(tx,ty,tr,tvx,tvy,h)
    {
        aimx=f.px;aimy=f.py;
    }
void boss_1_4::clone(bullet *h)
    {
        new boss_1_4(x,y,r,vx,vy,h);
    }
void boss_1_4::show()
    {
        glColor3d(1.0,0.5,0.0);
        glBegin(GL_LINES);
            glVertex2d(aimx,0);
            glVertex2d(aimx,sch);
            glVertex2d(0,aimy);
            glVertex2d(scw,aimy);
        glEnd();
        glColor3d(1.0,0.0,0.0);
        drawcircle(x,y,r);
        glColor3d(0.0,0.0,1.0);
        drawcircle(x,y,r/2.0);
        glColor3d(0.0,0.0,0.0);
        drawcircle2(x,y,r);
    }
bool boss_1_4::move()
    {
        aimx=f.px;aimy=f.py;
        x=scw*(1+sin(t*0.014))/2.0;
        y=sch*(1+cos(t*0.006))/2.0;
        if((int)t>(int)tlast&&(!(rand()%10)))
        {
            new bullet(x,y,5.0,0.0,0.0,&f.head);
        }
        for(bullet *a=f.head.next;a!=&f.head;a=a->next)
        {
            if(a->vx==0.0&&a->vy==0.0)
            {
                if(abs(a->x-aimx)<a->r)
                {
                    a->c_r=1.0;
                    a->c_g=0.0;
                    a->c_b=0.0;
                    if(a->y<aimy) a->vy=1.0;
                    else a->vy=-1.0;
                }
                else if(abs(a->y-aimy)<a->r)
                {
                    a->c_r=0.0;
                    a->c_g=0.0;
                    a->c_b=1.0;
                    if(a->x<aimx) a->vx=1.0;
                    else a->vx=-1.0;
                }
            }
        }
        return true;
    }

